dojo.provide("dojo.app.myvalidatorDijit.validators.notEmpty");

dojo.declare("dojo.app.myvalidatorDijit.validators.notEmpty", null, {
    _elemValue : null,
    _element : null,
    constructor: function() {
      this._elemValue = {};
    },
    setElementValue: function(elementValue) {
        this._elemValue = elementValue;
    },
    setElement: function(element) {
        this._element = element;
    },
    
    getErrorMessage: function(locale, messagesCur) {
        dojo.mixin(this.errorMessages, messagesCur);
        return this.errorMessages[locale];
    },
    
    //Type here default error message for this validator. It's could be replaced
    //by validation options for every used element.
    //You can use %value% to place a current value of validated element
    //You can use %neededValue% to place a value that is compared with %value%
    errorMessages: {"en" : "Value can\'t be empty!",
                    "ru" : "Значение не может быть пустым"},
    validate: 
        //Type here your validation function
        //Use this._elemValue as a value of your validated element
        //    neededValue as a value to compare with this._elemValue
        //Function must returns true if validation is not successful
        //                      false otherwise
        function(neededValue) {
            if (this._elemValue == "") {
                return true;
            } else {
                return false;
            };
        }
});


